<div class="row">
  <div class="span3 bs-docs-sidebar ">
 	<*include file="<*$controller*>/location.tpl"*>
  </div>

<div class="span7" style="margin-top:20px;">

<button class="btn btn-primary " onClick="window.location.href='/<*$controller*>/changeclass?studentname=<*$cnname*>'">返回</button>          
</div>

<div class="alert span7" style=" margin-top:10px;">
  <strong>说明：</strong> 正在将要搜索的信息合并至 <strong><*$cnname*></strong> 家长登陆帐号
</div>

   <div class="span7" style="margin-left:330px;">  
       <form name="form1"  method="get" class="form-horizontal" action="/<*$controller*>/opchange/uid_class/<*$uid_class*>/cnname/<*$cnname*>/student_uid/<*$student_uid*>"> 
          机构:<select id="jigou" name="groups"  onchange="getSchool(this.value)"></select>
          校园:<select id="school" name="school"  onchange="getClass(this.value)"></select> <br /><br />
          班级:<select id="class1" name="class" ></select>
          <input type="submit" class="btn btn-success"  value="查询"  >
          <input type="button" class="btn btn-success" value="清空查询" onclick="window.location='/mergeparents/opchange/uid_class/<*$uid_class*>/cnname/<*$cnname*>/student_uid/<*$student_uid*>'" >
       </form>
	</div>
    
    <*if $student*>
    <div class="span7" style="margin-left:330px; margin-top:20px;">
<form action="/<*$controller*>/opchangeclass" method="post" onsubmit="return checkhtml();"  id="f1" >    
   <table cellpadding="0" cellspacing="0" class="table">
		<tr> 
            <th class="span2">所属校园</th>
			<th class="span2">所属班级</th>
			<th class="span2">班级id</th>
			<th class="span2">班级uid</th>
			<th class="span2">姓名</th>
			<th class="span2">学生id</th>
			<th class="span2">学生uid</th>
			<th class="span2"><input type="checkbox" title="全选" name="qxhtml" id="qxhtml" style="background:none" value="1" onclick="xuanhtml();"/></th>
			<th>&nbsp;</th>
		</tr>
      
    	<*foreach from=$student item=a key =key name=foo*>
		<tr> 
            <td><*$a.schoolname*></td>
			<td><*$a.classname*></td>
			<td><*$a.classid*></td>
			<td><*$a.class_uid*></td>
			<td><*$a.cnname*></td>
			<td><*$a.studentid*></td>
			<td><*$a.uid*></td>
			<td><label><input type="checkbox" style="float:left;background:none" onclick="checkedov(<*$a.studentid*>)" name="htmlid[]" id="<*$a.studentid*>" value="<*$a.studentid*>" /></label>	
            
            	<input type="hidden" name="class_uid[]" id="class_uid" value="<*$a.class_uid*>"/>			
            	<input type="hidden" name="a_student_uid[]" id="a_student_uid" value="<*$a.uid*>"/>			
            </td>
            <td>&nbsp;</td>
		</tr> 
		<*/foreach*>
         <tr><th colspan="9"><button type="submit" class="btn-large btn-primary span7" >合并</button></th></tr>
    </table>
	<input type="hidden" name="student_uid" id="student_uid" value="<*$student_uid*>"/>
	<input type="hidden" name="groupid" id="groupid" value="<*$groups*>"/>
	<input type="hidden" name="cnname" id="cnname" value="<*$cnname*>"/>
</form>
	<input type="hidden" name="ischecked" id="ischecked" value="0"/>
    <*elseif $student eq 0*>
    <div class="alert alert-error span7" style="margin-left:330px; margin-top:10px;">
    	<strong>警告：</strong> 没有在其它班级找到叫<*$cnname*>的孩子！
    </div>
    </div>
    <*/if*>	 
    
</div>
</div>
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript"> 

  window.onload=function(){
	 jigou(); 

	if('<*$groups*>' != ''){
		getSchool('<*$groups*>');
	}
	if('<*$school_id*>' != ''){
		getClass('<*$school_id*>');
	}

 } 
function jigou()
{  

	var url     = '/<*$controller*>/groups/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_course});

} 
function showResponse_course(originalRequest)
{
	{  //alert(originalRequest.responseText);  
		 document.all.form1.groups.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$groups*>' != ''){
			 jsSelectIsExitItem(document.all.form1.groups,'<*$groups*>');
	        } 
	 }

}  

function getSchool(a)
{  
	var url  = '/<*$controller*>/schoollist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_school});

} 
function showResponse_school(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.school.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$school_id*>' != ''){
				jsSelectIsExitItem(document.all.form1.school,'<*$school_id*>');
			}
	 } 
}  
function getClass(a)
{  
     
	var url  = '/<*$controller*>/classlist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_class});

} 
function showResponse_class(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.class.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		  if('<*$classid*>' != ''){
				jsSelectIsExitItem(document.all.form1.class,'<*$classid*>');
			}
	 } 
}  

 function jsSelectIsExitItem(objSelect, objItemValue) {
	//alert(objSelect.options.length);
    for (var i = 0; i < objSelect.options.length; i++) {
        if (objSelect.options[i].value == objItemValue) { 
			objSelect.options[i].selected=true;
        	 break;
        }
    }
    return 1;
}  
 
 
function checkhtml(){
	var checkboxs=document.getElementsByName("htmlid[]");
	var clength=checkboxs.length;
	var isc=0;
	for (var i=0;i<clength;i++) {
		var e=checkboxs[i].value;
		var es=document.getElementById(e);
		if(es.checked==true){
			isc=1;
		}
	}
	if(isc==0){
		alert('请选择！');
		return false;
	}
	return true;
}

function checkedov(id){
	var ischecked=document.getElementById("ischecked");
	var ids=document.getElementById(id);
	if(ids.checked==true){
		ischecked.value=1;
	}
}

function xuanhtml() {
	var qxhtml=document.getElementById("qxhtml");
	var checkboxs=document.getElementsByName("htmlid[]");
	var ischecked=document.getElementById("ischecked");
	if(qxhtml.checked==true){
		for (var i=0;i<checkboxs.length;i++) {
			var e=checkboxs[i];
			e.checked=true;
		}
		ischecked.value=1;
	}else{
		for (var i=0;i<checkboxs.length;i++) {
			var e=checkboxs[i];
			e.checked=false;
		}
		ischecked.value=0;
	}
}

</script>
